﻿

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>修改菜单</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
</head>
<body>
    <div class="layui-form" lay-filter="layuiadmin-form-useradmin" id="layuiadmin-form-useradmin" style="padding: 20px 0 0 0;">
        <div class="layui-form-item" id="yjmenu">
            <label class="layui-form-label">上级菜单</label>
            <div class="layui-input-inline">
                <input type="text" name="parentmenuname" readonly="readonly" id="parentmenuname" autocomplete="off" class="layui-input">
                <input type="hidden" id="parentmenuid">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单名称</label>
            <div class="layui-input-inline">
                <input type="text" name="menuname" id="menuname" lay-verify="required" placeholder="请输入菜单名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">菜单地址</label>
            <div class="layui-input-inline">
                <input type="text" name="menuurl" id="menuurl" placeholder="请输入菜单地址" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">序号</label>
            <div class="layui-input-inline">
                <input type="text" name="menuxh" id="menuxh" placeholder="请输入序号" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <input type="text" name="menuremark" id="menuremark" placeholder="请输入备注" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item" lay-filter="sex">
            <label class="layui-form-label">是否可用</label>
            <div class="layui-input-block">
                <input type="checkbox" id="isactive" checked="" name="open" lay-skin="switch" lay-filter="component-form-switchTest" lay-text="可用|禁用">
            </div>
        </div>
        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
        </div>
    </div>

    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/js/jquery.min2.1.4.js"></script>
    <script src="../../../layuiadmin/js/jshelp.js"></script>
    <script>
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(decodeURI(r[2])); return null; //返回参数值
        }
        var editid = getUrlParam('editid');
        var level = getUrlParam('level');
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'upload'], function () {
            var $ = layui.$
                , form = layui.form
                , upload = layui.upload;
            if (level == "0") {
                $("#yjmenu").hide();
            }
            //加载修改信息
            $.ajax({
                url: 'ashx/list.ashx?type=getlist_byid&editid=' + editid,
                type: 'GET',
                success: function (data) {
                    var str = "";
                    for (var i = 0; i < data.data.length; i++) {
                        $("#parentmenuname").val(data.data[i].parentmenuname);
                        $("#parentmenuid").val(data.data[i].pid);
                        $("#menuname").val(data.data[i].title);
                        $("#menuurl").val(data.data[i].menuurl);
                        $("#menuxh").val(data.data[i].xh);
                        $("#menuremark").val(data.data[i].remark);
                      
                        var isactive = $("#isactive").prop("checked");//是否可用
                        if (data.data[i].isactive == 'Y') {
                            $("#isactive").attr("checked", "checked");
                            $("#isactive").attr("value", '可用');
                        }
                        else {
                            $("#isactive").removeAttr("checked");
                            var x = document.getElementsByClassName("layui-unselect layui-form-switch layui-form-onswitch");
                            x[0].setAttribute("class", "layui-unselect layui-form-switch");
                            var d = document.getElementsByTagName('em')[0];
                            d.firstChild.nodeValue = '禁用';
                        }
                    }
                }
            })
            //创建上传组件
            //upload.render({
            //    elem: '#layuiadmin-upload-useradmin',
            //    url: '../../../ashx/upload_img.ashx',
            //    dataType: "json",
            //    accept: 'images', //允许上传的文件类型
            //    acceptMime: 'image/*',
            //    size: 1000, //最大允许上传的文件大小,
            //    data: function () {
            //        //请求上传接口的额外参数
            //    },
            //    done: function (res) {
            //        if (res.code === "100") {
            //            layer.msg(res.msg);
            //            //$(this.item).prev("div").children("input").val(res.url)
            //            $("#imgurl").val(res.url);
            //        } else {
            //            layer.msg(res.msg);
            //        }
            //    },
            //    error: function () {
            //        layer.msg("请求异常！");
            //    }
            //});
        })
       
    </script>
</body>
</html>